package com.fengxing.ams.web.task;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.fengxing.ams.web.facade.mouble.company.EnterpriseNotifyVO;
import com.fengxing.ams.web.facade.mouble.company.ICompanyImportDAO;
import com.fengxing.ams.web.facade.mouble.company.IEnterpriseNotifyDAO;

@Component
public class EnterpriseNotifyTask {

	private static final Log logger = LogFactory.getLog(EnterpriseNotifyTask.class);
	
	@Autowired
	IEnterpriseNotifyDAO enterpriseNotifyDAO;
	
	@Autowired
	ICompanyImportDAO comanyImportDAO;
	
	public void notifyAction() {
		long lastTime = System.currentTimeMillis();
		logger.info("notifyAction start:" + lastTime);
		
		//查询未处理的通知任务
		List<EnterpriseNotifyVO> list = enterpriseNotifyDAO.findAllIds();
		//查看是否在运行时段
		for (EnterpriseNotifyVO notify : list) {
			String time = notify.getSendDate() + " " +notify.getSendTime();
			try {
				Date sendTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(time);
				if (Calendar.getInstance().getTime().after(sendTime)) {
					//开始发送
					List<String> emails = comanyImportDAO.findAllEmail();
					for (String email : emails) {
						
					}
				}
			} catch (ParseException e) {
			}
		}
		
		
		
		//查看
		
		logger.info("notifyAction end:" + (System.currentTimeMillis() - lastTime));
	}
	
}